package com.itchen.school.common.base;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.Serializable;
import java.util.Objects;

public class BaseBizEntity<T extends Model<?>> extends Model<T> {

    @TableField( fill = FieldFill.INSERT )
    protected String id;

    @TableField( fill = FieldFill.INSERT )
    protected Integer sort;

    @TableField( exist = true )
    protected String description;

    @TableField( fill = FieldFill.INSERT )
    protected Integer recordStatus;

    @TableField( fill = FieldFill.INSERT )
    protected String creator;

    @TableField( fill = FieldFill.INSERT )
    protected String creatorName;

    @TableField( fill = FieldFill.INSERT )
    protected String createTime;

    @TableField( fill = FieldFill.UPDATE )
    protected String updater;

    @TableField( fill = FieldFill.UPDATE )
    protected String updaterName;

    @TableField( fill = FieldFill.UPDATE )
    protected String updateTime;

    public BaseBizEntity() {}

    public Serializable pkVal() {
        return this.id;
    }

    public static void emptyCommonFields(BaseBizEntity et) {
        et.setCreator((String)null);
        et.setCreatorName((String)null);
        et.setUpdater((String)null);
        et.setUpdaterName((String)null);
        et.setDescription((String)null);
        et.setRecordStatus((Integer)null);
        et.setSort((Integer)null);
        et.setCreateTime((String)null);
        et.setUpdateTime((String)null);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getRecordStatus() {
        return recordStatus;
    }

    public void setRecordStatus(Integer recordStatus) {
        this.recordStatus = recordStatus;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdater() {
        return updater;
    }

    public void setUpdater(String updater) {
        this.updater = updater;
    }

    public String getUpdaterName() {
        return updaterName;
    }

    public void setUpdaterName(String updaterName) {
        this.updaterName = updaterName;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BaseBizEntity<?> that = (BaseBizEntity<?>) o;
        return Objects.equals(id, that.id) && Objects.equals(sort, that.sort) && Objects.equals(description, that.description) && Objects.equals(recordStatus, that.recordStatus) && Objects.equals(creator, that.creator) && Objects.equals(creatorName, that.creatorName) && Objects.equals(createTime, that.createTime) && Objects.equals(updater, that.updater) && Objects.equals(updaterName, that.updaterName) && Objects.equals(updateTime, that.updateTime);
    }

    protected boolean canEqual(Object other) {
        return other instanceof BaseBizEntity;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, sort, description, recordStatus, creator, creatorName, createTime, updater, updaterName, updateTime);
    }

    @Override
    public String toString() {
        return "BaseBizEntity{" +
                "id='" + id + '\'' +
                ", sort=" + sort +
                ", description='" + description + '\'' +
                ", recordStatus=" + recordStatus +
                ", creator='" + creator + '\'' +
                ", creatorName='" + creatorName + '\'' +
                ", createTime='" + createTime + '\'' +
                ", updater='" + updater + '\'' +
                ", updaterName='" + updaterName + '\'' +
                ", updateTime='" + updateTime + '\'' +
                '}';
    }

}
